package com.ujiuye.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/demo09Servlet")
public class Demo09Servlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置字符集
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        String username = req.getParameter("username");

        //把list集合当成数据库
        List<String> lists = new ArrayList<>();
        lists.add("zhangsan");
        lists.add("lisi");
        lists.add("wangwu");
        lists.add("zhaoliu");
        lists.add("tianqi");

       //true  不让注册  false  让注册
        resp.getWriter().print(lists.contains(username));
    }
}
